package io.renren.modules.job.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.renren.modules.common.BaseService;
import io.renren.modules.job.dao.ScheduleJobLogDao;
import io.renren.modules.job.entity.ScheduleJobLogEntity;
import io.renren.modules.job.pojo.ScheduleJobLogQuery;
import io.renren.modules.job.service.ScheduleJobLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("scheduleJobLogService")
public class ScheduleJobLogServiceImpl extends BaseService
		implements ScheduleJobLogService {
	@Autowired
	private ScheduleJobLogDao scheduleJobLogDao;
	
	@Override
	public ScheduleJobLogEntity queryObject(Long jobId) {
		return scheduleJobLogDao.queryObject(jobId);
	}

	@Override
	public List<ScheduleJobLogEntity> queryList(ScheduleJobLogQuery query) {
		return scheduleJobLogDao.queryList(query);
	}

	@Override
	public PageInfo<ScheduleJobLogEntity> queryPage(ScheduleJobLogQuery query) {
		return PageHelper.startPage(query.getPage(),query.getLimit())
				.doSelectPageInfo(() -> scheduleJobLogDao.queryList(query));
	}

	@Override
	public long queryTotal(ScheduleJobLogQuery query) {
		return PageHelper.count(() -> scheduleJobLogDao.queryList(query));
	}

	@Override
	@Transactional
	public void save(ScheduleJobLogEntity log) {
		scheduleJobLogDao.save(log);
	}

}
